package com.kning.mastermind;

/**
 * MatchResultEnum - 匹配结果枚举
 *
 * @author ning
 **/
public enum MatchResultEnum {
    A0B0("A0B0", 0b0000_0000),
    A0B1("A0B1", 0b0000_0001),
    A0B2("A0B2", 0b0000_0010),
    A0B3("A0B3", 0b0000_0011),
    A0B4("A0B4", 0b0000_0100),
    A1B0("A1B0", 0b0001_0000),
    A1B1("A1B1", 0b0001_0001),
    A1B2("A1B2", 0b0001_0010),
    A1B3("A1B3", 0b0001_0011),
    A2B0("A2B0", 0b0010_0000),
    A2B1("A2B1", 0b0010_0001),
    A2B2("A2B2", 0b0010_0010),
    A3B0("A3B0", 0b0011_0000),
    A3B1("A3B1", 0b0011_0001),
    A4B0("A4B0", 0b0100_0000);


    public String code;
    public int value;

    MatchResultEnum(String code, int value) {
        this.code = code;
        this.value = value;
    }

    public static String getCode(int value) {
        for (MatchResultEnum matchResult : values()) {
            if (matchResult.value == value) {
                return matchResult.code;
            }
        }
        return "ERROR";
    }
}
